<template>
    <div class="stocks">
        <div class="header">
            <div class="title">Stocks</div>
            <div class="more">
                <!-- 后面补充一个搜索框用于搜索股票用于选择 -->
            </div>
        </div>
        <div class="table">
            <table>
                <thead>
                    <tr>
                        <th>SYMBOL</th>
                        <th>NAME</th>
                        <th>PRICE</th>
                        <th>CHANGE</th>
                        <!-- <th>VOLUME</th>
                        <th>MARKET CAP</th> -->
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in stock_list" :key="item.id">
                        <td>{{ item.symbol }}</td>
                        <td>{{ item.name }}</td>
                        <td>{{ item.price }}</td>
                        <td :style="`color: ${ parseFloat(item.change) >= 0 ? 'var(--positive-number-color)' : 'var(--negative-number-color)' }`">{{ item.change }}</td>
                        <!-- <td>{{ item.volume }}</td>
                        <td>{{ item.market_cap }}</td> -->
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</template>

<script setup>
import { stock_list } from '@/service/market.js';
</script>

<style scoped lang="less">
.stocks {
    box-sizing: border-box;
    width: 100%;
    padding: 1.5vw;
    display: flex;
    flex-direction: column;
    gap: 1vw;
    background-color: #fff;
    box-shadow: 0 0 0.5vw rgba(0, 0, 0, 0.05);
    border-radius: 0.5vw;

    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .title {
            font-size: 1.1vw;
            font-weight: 600;
            color: var(--text-color);
        }

    }

    .table {
        width: 100%;
        
        table {
            width: 100%;
            border-collapse: collapse;

            thead {
                height: 3vw;
                background-color: var(--bg-color);

                th {
                    padding: 1vw;
                    font-size: 0.8vw;
                    text-align: left;
                    font-weight: 500;
                    color: var(--text-light-color);
                }
            }

            tbody {
                tr {
                    height: 3vw;
                    border-top: 0.1vw solid var(--border-color);

                    td {
                        padding: 1vw;
                        font-size: 0.7vw;
                        text-align: left;
                        color: var(--text-color);
                    }
                }
            }
        }
    }
}
</style>